<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <link href="../style/authority/basic_layout.css" rel="stylesheet" type="text/css">
    <link href="../style/authority/common_style.css" rel="stylesheet" type="text/css">
    <link href="../style/authority/zTreeStyle.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="../style/bootstrap.min.css"/>
    <script type="text/javascript" src="../scripts/jquery/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="../scripts/zTree/jquery.ztree.core-3.2.js"></script>
    <script type="text/javascript" src="../scripts/fancybox/jquery.fancybox-1.3.4.js"></script>
    <script type="text/javascript" src="../scripts/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
    <link rel="stylesheet" type="text/css" href="../style/authority/jquery.fancybox-1.3.4.css" media="screen"/>
    </link>
    <script type="text/javascript" src="../scripts/artDialog/artDialog.js?skin=default"></script>
    <script type="text/javascript" src="../scripts/bootstrap.min.js"></script>
    <script type="text/javascript" src="../scripts/jquery.js"></script>
    <script type="text/javascript" src="../scripts/bootstrap.js"></script>
    <title>信息管理系统</title>
    <style type="text/css">
        #sider {
            position: absolute;
            top: 0;
            left: 25px;
            bottom: 0px;
            width: 260px;
            border: 1px solid #DEDFDF;
        }

        #main {
            position: absolute;
            top: 0;
            left: 285px;
            right: 0px;
            bottom: 0px;
            border: 1px solid #DEDFDF;
            overflow: auto;
        }

        #fang_type li {
            width: 80px;
            height: 22px;
            line-height: 22px;
            color: #FFF;
            display: inline-block;
        }

        li {
            list-style-type: none;
        }
    </style>
</head>

<body>
<div id="container">
    <div id="sider">
        <!--<ul id="tree" class="ztree"></ul>-->
        <div class="tree well ">
            <!--左边树形菜单栏-->
            <ul style="width:280px;">
                <li>
                    <span>
                        <i class="glyphicon glyphicon-option-horizontal"></i>
                            待办类型
                    </span>
                    <ul>
                        <li>
                            <i class="glyphicon glyphicon-option-vertical"></i>
                            <a href="#" onclick="onBacklog(1)">计划审批</a>
                        </li>
                        <li>
                            <i class="glyphicon glyphicon-option-vertical"></i>
                            <a href="#" onclick="onBacklog(2)">立项审批</a>
                        </li>
                        <li>
                            <i class="glyphicon glyphicon-option-vertical"></i>
                            <a href="" onclick="onBacklog(3)">征求意见稿审批</a>
                        </li>
                        <li>
                            <i class="glyphicon glyphicon-option-vertical"></i>
                            <a href="" onclick="onBacklog(4)">正式稿审批</a>
                        </li>
                    </ul>
                </li>
            </ul>

        </div>
    </div>
    <div id="main">
        <!--<div>-->
        <!--<div align="left" style="background-color: #E7E7E7;"><span class="glyphicon glyphicon-play"></span><span-->
        <!--style="color: #990000;">&nbsp;处理</span></div>-->
        <!--</div>-->
        <div>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th width="26%" class="text-center">代办类型</th>
                    <th width="26%" class="text-center">发送人</th>
                    <th width="33%" class="text-center">发送时间</th>
                    <th width="15%" class="text-center">操作</th>
                </tr>
                </thead>
                <tbody id="order01">

                </tbody>
            </table>
        </div>
    </div>
</div>

<!--审批的模态框-->
<div class="modal fade" id="shenpi">
    <div class="modal-dialog">
        <div class="modal-content" style="width: 600px;">
            <div class="modal-header">
                <button class="close" data-dismiss="modal">×</button>
                <p>
                    <span style="font-size:16px; font-weight:normal">审批</span>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <span id="hint" style="color: red"></span>
                </p>
            </div>
            <form action="#" method="post">
                <div class="media-body container">
                    <br>
                    <table class="table table-condensed col-md-12">
                        <tr valign="middle" align="center">
                            <td width="30%">项目名称:</td>
                            <td width="70%" colspan="3">
                                <input type="hidden" id="audit" name="audit" value="">
                                <input type="hidden" id="auditId" name="auditId" value="">
                                <input type="text" class="btn-block" id="event" name="event" value=""
                                       readonly="readonly">
                            </td>
                        </tr>
                        <tr valign="middle" align="center">
                            <td>处理操作:</td>
                            <td colspan="3">
                                <select name="operations" class="btn-block" id="operations">
                                    <option value="2">--请选择--</option>
                                    <option value="0">不同意</option>
                                    <option value="1">同意</option>
                                </select>
                            </td>
                        </tr>
                        <tr valign="middle" align="center">
                            <td>处理意见:</td>
                            <td colspan="3">
                                    <textarea class="btn-block" id="opinion" name="opinion"
                                              style="height: 70px;resize:none">无</textarea>
                            </td>
                        </tr>
                        <tr valign="middle" align="center">
                            <td width="25%">处理人:</td>
                            <td width="25%"><input type="text" readonly="readonly"
                                                   style="background-color: #4c5a5f"/></td>
                            <td width="25%">处理时间:</td>
                            <td width="25%"><input type="text" readonly="readonly"
                                                   style="background-color: #4c5a5f"/></td>
                        </tr>
                    </table>
                </div>
                <div class="modal-footer">
                    <button type="button" id="sub" class="btn btn-info btn-block" onclick="submitInspect()">提交</button>
                    <input type="button" class="btn btn-warning btn-block" data-dismiss="modal" value="取消"/>
                </div>
            </form>
        </div>
    </div>
</div>
<!--结束-->

</body>
</html>
<script type="text/javascript">
    $(function () {
        $('.tree li:has(ul)').addClass('parent_li').find(' > span').attr('title', 'Collapse this branch');
        $('.tree li.parent_li > span').on('click', function (e) {
            var children = $(this).parent('li.parent_li').find(' > ul > li');
            if (children.is(":visible")) {
                children.hide('fast');
                $(this).attr('title', 'Expand this branch').find(' > i').addClass('icon-plus-sign').removeClass('icon-minus-sign');
            } else {
                children.show('fast');
                $(this).attr('title', 'Collapse this branch').find(' > i').addClass('icon-minus-sign').removeClass('icon-plus-sign');
            }
            e.stopPropagation();
        });
    });

    function onBacklog(elect) {
        $.ajax({
            type: "GET",
            url: "/Leader/AjaxFindBacklog",
            dataType: 'json',
            data: {"elect": elect},
            success: function (data) {
                var html = '';
                if (data.correlations != null) {
                    if (parseInt(data.elect) == 1) {
                        for (var i = 0; i < data.correlations.length; i++) {
                            html += '<tr>' +
                                '<td class="text-center">' + data.correlations[i].auditPlan.name + '</td>' +
                                '<td class="text-center">' + data.correlations[i].user.name + '</td>' +
                                '<td class="text-center">' + data.correlations[i].auditPlan.creationdate + '</td>' +
                                '<td class="text-center">' +
                                '<a href="#" class="approval" onclick="js_shenPi(1,' + data.correlations[i].auditPlan.id + ')">' +
                                '<input type="button" class="btn btn-info btn-block" value="查看">' +
                                '</a>' +
                                '</td>' +
                                '</tr>';

                        }
                    } else if (parseInt(data.elect) == 2) {
                        for (var i = 0; i < data.correlations.length; i++) {
                            html += '<tr>' +
                                '<td class="text-center">' + data.correlations[i].project.name + '</td>' +
                                '<td class="text-center">' + data.correlations[i].user.name + '</td>' +
                                '<td class="text-center">' + data.correlations[i].project.creationdate + '</td>' +
                                '<td class="text-center">' +
                                '<a href="#" class="approval" onclick="js_shenPi(2,' + data.correlations[i].project.id + ')">' +
                                '<input type="button" class="btn btn-info btn-block" value="处理">' +
                                '</a>' +
                                '</td>' +
                                '</tr>';

                        }
                    }
                } else {
                    html += '<tr><td class="text-center" colspan="4"><b>暂无数据</b></td></tr>'
                }
                $("#order01").empty();
                $("#order01").append(html);
            }
        });
    }

    function js_shenPi(elect, id) {
        $(".approval").attr('data-toggle', 'modal');
        $(".approval").attr('data-target', '#shenpi');
        $.ajax({
            type: "GET",
            url: "/Leader/AjaxApprovalById",
            dataType: 'json',
            data: {"elect": elect, "id": id},
            async: false,
            success: function (data) {
                $("#audit").val(data.elect);
                $("#auditId").val(data.id);
                $("#event").val(data.byId.name);
            }
        });
    }

    function submitInspect() {
        var falg;
        var audit = $("#audit").val();
        var auditId = $("#auditId").val();
        var event = $("#event").val();
        var operations = $("#operations").val();
        var opinion = $("#opinion").val();

        function showErrorMess(ms) {
            falg = false;
            $("#hint").html(ms);
        }

        $("#sub").attr('data-dismiss', 'modal');

        if (auditId == null || auditId == "") {
            showErrorMess("系统错误！！！");
            $("#sub").removeAttr("data-dismiss");
        } else if (audit == null || audit == "") {
            showErrorMess("系统错误！！！");
            $("#sub").removeAttr("data-dismiss");
        } else if (event == null || event == "") {
            showErrorMess("你真牛逼，项目名称都被你弄丢了！");
            $("#sub").removeAttr("data-dismiss");
        } else if (parseInt(operations) == parseInt(2)) {
            showErrorMess("请选择处理操作！");
            $("#sub").removeAttr("data-dismiss");
        } else if (opinion == null || opinion == "") {
            showErrorMess("处理意见？？？");
            $("#sub").removeAttr("data-dismiss");
        } else {
            falg = true;
        }

        if (falg == true) {
            $.ajax({
                type: "GET",
                url: "/Leader/AjaxApproval",
                dataType: 'json',
                data: {
                    "audit": audit,
                    "auditId": auditId,
                    "event": event,
                    "operations": operations,
                    "opinion": opinion
                },
                async: false,
                success: function (feedback) {
                    if (feedback == true) {
                        location.reload(true);
                    }
                }
            });
        }

    }
</script>
<!--
	作者：钟琪
	时间：2019-05-10
	描述：
-->